import Request from '@/utils/request'

/**
 * 课程相关API
 */
export default {
  /**
   * 获取首页横幅广告
   * @param {number} limit 数量限制
   */
  getHomeBanners(limit = 5) {
    return Request.get('/api/home/banners', { limit })
  },
  /**
   * 获取课程列表
   * @param {object} params 查询参数
   */
  getCourseList(params = {}) {
    return Request.get('/api/customer/course/list', params)
  },

  /**
   * 获取课程详情
   * @param {number} courseId 课程ID
   */
  getCourseDetail(courseId) {
    return Request.get(`/api/customer/course/detail/${courseId}`)
  },

  /**
   * 搜索课程
   * @param {object} params 搜索参数
   */
  searchCourse(params) {
    return Request.get('/api/customer/course/search', params)
  },

  /**
   * 获取热门课程
   * @param {number} limit 数量限制
   */
  getHotCourses(limit = 10) {
    return Request.get('/api/home/hot-courses', { limit })
  },

  /**
   * 获取推荐课程
   * @param {number} limit 数量限制
   */
  getRecommendCourses(limit = 10) {
    return Request.get('/api/home/recommend-courses', { limit })
  },

  /**
   * 获取课程分类
   */
  getCourseCategories() {
    return Request.get('/api/home/categories')
  },

  /**
   * 收藏课程
   * @param {number} courseId 课程ID
   */
  favoriteCourse(courseId) {
    return Request.post('/api/customer/course/favorite', { courseId })
  },

  /**
   * 取消收藏
   * @param {number} courseId 课程ID
   */
  unfavoriteCourse(courseId) {
    return Request.delete(`/api/customer/course/favorite/${courseId}`)
  },

  /**
   * 获取收藏列表
   * @param {object} params 查询参数
   */
  getFavoriteList(params = {}) {
    return Request.get('/api/customer/course/favorites', params)
  },

  /**
   * 添加浏览记录
   * @param {number} courseId 课程ID
   */
  addBrowseHistory(courseId) {
    return Request.post('/api/customer/course/browse', { courseId })
  },

  /**
   * 获取浏览历史
   * @param {object} params 查询参数
   */
  getBrowseHistory(params = {}) {
    return Request.get('/api/customer/course/browse/history', params)
  }
}